<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%car_gps_order_status_update_log}}".
 *
 * @property integer $id
 * @property integer $order_id
 * @property integer $time
 * @property integer $old_status
 * @property integer $new_status
 * @property string $order_data
 *
 * @property CarGpsOrder $order
 */
class CarGpsOrderStatusUpdateLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%car_gps_order_status_update_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'time', 'new_status'], 'required'],
            [['order_id', 'time', 'old_status', 'new_status'], 'integer'],
            [['order_data'], 'string'],
            [['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => CarGpsOrder::className(), 'targetAttribute' => ['order_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'order_id' => 'Order ID',
            'time' => 'Time',
            'old_status' => 'Old Status',
            'new_status' => 'New Status',
            'order_data' => 'Order Data',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOrder()
    {
        return $this->hasOne(CarGpsOrder::className(), ['id' => 'order_id']);
    }
}
